<template>
	<view>
		<nav-custom :name="title"></nav-custom>
		<view class="list">
			<view class="list_a">
				<image class="a_img" :src="url+'/image/qbback.png'" mode=""></image>
				<view class="list_a_a">
					<view class="a_a_left dis_f_sb_c">
						<view>
							<view class="white_f_28 bor_b_16">我的资产(元)</view>
							<view class="white_f_52">{{info.my_assets}}</view>
						</view>
						<image class="jf_img" :src="url+'/image/jficon.png'" mode=""></image>
					</view>
					<view class="dis_f_l_c white_f_28">
						<view class="a_text">可提现 ￥{{info.withdrawable}}</view>
						<view class="a_text">已提现 ￥{{info.withdrawn}}</view>
					</view>
				</view>
			</view>
			<view class="back list_b dis_f_sb_c" @click="show = true">
				<view class="black_s_28">提现至</view>
				<view class="dis_f_r_c">
					<view class="black_f_28">
						{{bank}}
					</view>
					<image class="r_img" :src="url+'/image/right.png'" mode=""></image>
				</view>
			</view>
			<view class="back list_b">
				<view class="black_s_28">提现金额</view>
				<view class="list_b_b dis_f_sb_c">
					<view class="dis_f_l_c">
						<view class="black_f_52">￥</view>
						<view>
							<u--input placeholder=" " border="none" v-model="value" type="digit"></u--input>
						</view>
					</view>
					<view class="blue_f_28" @click="tixian()">全部提现</view>
				</view>
			</view>
		</view>
		<view>
			<u-picker :show="show" @confirm="confirm" @cancel="cancel" :columns="columns" keyName="name"></u-picker>
		</view>
		<view class="bule_back_but white_f_32 bot_wz" @click="submit()">
			确认提现
		</view>
		<!-- <image class="bo_js_img" src="../../static/image/zcxian.png" mode=""></image> -->
	</view>
</template>

<script>
	export default {
		data() {
			return {
				title: "提现",
				bank: "",
				bank_id:0,
				value: '',
				show: false,
				money:18552.05,
				columns: [
					// ['微信', '建设银行(6648)', '建设银行(6648)', '农业银行(6648)', '工商银行(6648)']
				],
				info:[],
				is_submit:0,
				url:''
			}
		},
		onShow() {
			this.url=this.$.ajax_url3
			this.get_info()
			this.get_list()
		},
		methods: {
			submit(){
				let money = this.value*1
				if(money <= 0){
					this.$.ti_shi('请输入提现金额')
				}
				if(this.bank_id <= 0){
					this.$.ti_shi('请选择银行卡')
				}
				if(this.is_submit == 0){
					this.is_submit = 1;
					this.$.ajax(1,'post','store/store/store_withdrawal',{
						money:money,
						store_bank_id:this.bank_id
					},(res)=>{
						this.$.ti_shi(res.msg)
						if(res.code == 200){
							setTimeout(()=>{
								this.$.back()
							},600)
						}else{
							this.is_submit = 0;
						}
					});
				}
			},
			get_list(){
				this.$.ajax(1,'post','store/store/my_bank',{},(res)=>{
					if(res.code == 200){
						let list = [];
						res.data.forEach((item,index)=>{
							let tem = {
								id:item.id,
								name:item.bankname+'('+item.after+')'
							}
							list.push(tem)
						})
						this.columns = [list]
						if(list.length > 0){
							this.bank = list[0].name
							this.bank_id = list[0].id
						}
					}else{
						this.$.ti_shi(res.msg)
					}
				});
			},
			get_info(){
				this.$.ajax(1,'post','store/store/my_wallet',{},(res)=>{
					if(res.code == 200){
						this.info = res.data
						this.money = res.data.withdrawable
					}else{
						this.$.ti_shi(res.msg)
					}
				});
			},
			cancel(){
					this.show = false
			},
			confirm(n){
				// console.log(n);
				this.bank = n.value[0].name
				this.bank_id = n.value[0].id
				this.show = false
			},
			tixian(){
				this.value = this.money
			}
		}
	}
</script>

<style lang="scss">
	.list_a {
		width: 686rpx;
		height: 320rpx;
		position: relative;
		margin-bottom: 24rpx;

		.a_img {
			width: 686rpx;
			height: 320rpx;
			position: absolute;
			top: 0;
			left: 0;
		}

		.list_a_a {
			position: absolute;
			top: 40rpx;
			left: 40rpx;

			.a_a_left {
				width: 590rpx;
			}

			.jf_img {
				width: 144rpx;
				height: 144rpx;
			}
		}

		.a_text {
			margin-top: 48rpx;
			margin-right: 48rpx;
		}
	}

	.list_b {
		margin-bottom: 24rpx;

		.r_img {
			width: 32rpx;
			height: 32rpx;
		}

		.list_b_b {
			padding-bottom: 10rpx;
			border-bottom: 2rpx solid #F7F7F7;
			margin-top: 40rpx;
		}
	}
</style>